feat: add users and groups support#7
Conversation
|
This looks great! The api changes will need to be moved to https://github.com/deevus/truenas-go as services. Once that lands, it should be fairly simple to consume those here as resources. |
|
Rebase and integrate Once tested and confirmed working I will merge upstream. |
7c28a60 to
f18897e
Compare
|
found a bug: resource "truenas_group" "test" { name = "test" }
resource "truenas_user" "test" {
username = "test"
full_name = "Test User"
email = "test@mirceanton.com"
shell = "/usr/sbin/nologin"
group_id = truenas_group.test.id
groups = [data.truenas_group.builtin_users.id]
password = "test"
}This config causes the group to also be deleted if i delete the group. need to look into it some more. Will mark this PR as draft until then |
| filter := [][]string{{"group", "=", data.Name.ValueString()}} | ||
|
|
||
| result, err := d.client.Call(ctx, "group.query", filter) | ||
| result, err := d.services.Client.Call(ctx, "group.query", filter) |
There was a problem hiding this comment.
This is not what I meant. We shouldn't be calling Client.Call directly from terraform-provider-truenas anymore. In this case you probably want GroupService.GetByName
You will need to use a replace directive to use the code from deevus/truenas-go#11 (clone and checkout the branch locally).
Fixes #1
This PR adds support for managing both
truenas_usersandtruenas_groupsas resources as well as data sources.Disclaimer: I did use claude code to help me generate this code. Feel free to dismiss this PR if that does not align with the project goals. I saw a
CLAUDE.mdfile in the repo root so I assumed it would be fine.I have tested this in my homelab with this code: https://github.com/mirceanton/truenas-apps/tree/feat!/terraform/terraform/truenas